﻿using System;
using System.Runtime.Caching;
using GameViewModel;

namespace KolhozWeb.Controllers
{
    public static class Game
    {
        public static TheGame Instance
        {
            get
            {
                var cache = MemoryCache.Default;
                if (!cache.Contains("game"))
                {
                    var game = new TheGame();
                    InitGame(game);
                    cache.Add("game", game, DateTimeOffset.MaxValue);
                }
                return (TheGame)cache["game"];
            }

        }
        private static void InitGame(TheGame game)
        {
            game.Options.Persons.Clear();
            game.Options.Persons.Add(new Person("Евлампий", 1) { IsSelected = true });
            game.Options.Persons.Add(new Person("Сигизмунд", 2) { IsSelected = true });
            game.Options.Persons.Add(new Person("Ратибор", 3) { IsSelected = true });
            game.Options.Persons.Add(new Person("Гостомысл", 4) { IsSelected = true });
            game.Options.Persons.Add(new Person("Афиноген", 5) { IsSelected = true });
        }


    }
}